function viewDBTable(){
	var location = prompt("Please enter the table in the database that you want to load.",'');
	if (location === "" || location === null) {
		return;
	} else {
		var tab = dijit.byId("tableTab");
		if(!tab){
			var tab = new dojox.layout.ContentPane({
				id:"tableTab",
				title:"View '"+location.toUpperCase()+"' Table",
				href:'dev/tableview.php?table='+location,
				closable:true
			});
			dijit.byId("tabContainer").addChild(tab);
		}else{
			tab.setHref('dev/tableview.php?table='+location);
		}
		dijit.byId("tabContainer").selectChild(tab);
	}
}

function viewTodo(){
	var tab;
	
	if(!dijit.byId('toDo')){
		tab = new dijit.layout.ContentPane({
			id: "toDo",
			title:"To Do",
			href:'dev/todo.html',
			closable:true,
			preventCache:true
		});
		dijit.byId("tabContainer").addChild(tab);
	}else{
		tab=dijit.byId('toDo');
	}
	dijit.byId("tabContainer").selectChild(tab);
}

function viewSched(){
	var tab;
	
	if(!dijit.byId('schedule')){
		tab = new dijit.layout.ContentPane({
			id: "schedule",
			title:"Schedule",
			href:'dev/sched.html',
			closable:true,
			preventCache:true
		});
		dijit.byId("tabContainer").addChild(tab);
	}else{
		tab=dijit.byId('schedule');
	}
	dijit.byId("tabContainer").selectChild(tab);
}

function viewBugs(){
	var tab;
	
	if(!dijit.byId('bugs')){
		tab = new dijit.layout.ContentPane({
			id:"bugs",
			title:"Bugs",
			href:'dev/bugs.html',
			closable:true,
			preventCache:true
		});
		dijit.byId("tabContainer").addChild(tab);
	}else{
		tab=dijit.byId('bugs');
	}
	dijit.byId("tabContainer").selectChild(tab);
}

function viewJSON(jsonText){
	var tab = dijit.byId("jsonTab");
	
	if(!jsonText && dataStore){
		jsonText = dataStore._getNewFileContentString(true);	//avoid_referrencing: true
	}
	
	if(!tab){
		var tab = new dijit.layout.ContentPane({
			id:"jsonTab",
			title:"View JSON",
			content:'',
			closable:true
		});
		dijit.byId("tabContainer").addChild(tab);
	}
	
	dojo.xhrPost({
		url:"dev/viewJSON.php",
		postData:"data="+jsonText,
		load:function(response, ioArgs){
			tab.set('content',response);
			dijit.byId("tabContainer").selectChild(tab);
			return response;
		},
		error:function(error,ioArgs){
			alert("Save error. "+error);
			return error;
		}
	});
}

function viewConsole(ajaxResponse){
	var tab;
	
	if(!dijit.byId('console')){
		tab = new dijit.layout.ContentPane({
			id:"console",
			title:"Console",
			closable:true,
			content:ajaxResponse
		});
		dijit.byId("tabContainer").addChild(tab);
	}else{
		tab=dijit.byId('console');
		tab.set('content',ajaxResponse);
	}
	dijit.byId("tabContainer").selectChild(tab);
}
